//
//  RecommendGoodsCell.m
//  CenturyCity
//
//  Created by beisheng03 on 2017/12/12.
//  Copyright © 2017年 beisheng. All rights reserved.
//

#import "RecommendGoodsCell.h"
#import "RecomGoodsLayout.h"
#import "RecommdCollectionCell.h"

#import "GoodDetailController.h"
@interface RecommendGoodsCell ()<UICollectionViewDelegate,UICollectionViewDataSource>
@property (weak, nonatomic) IBOutlet UICollectionView *myCollectionView;

@end

@implementation RecommendGoodsCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.contentView.backgroundColor = randomColor;
    
     [self.myCollectionView registerNib:[UINib nibWithNibName:NSStringFromClass([RecommdCollectionCell class]) bundle:nil] forCellWithReuseIdentifier:[RecommdCollectionCell identifierStr]];
    
    self.myCollectionView.backgroundColor = viewBgGrey;
    
    self.myCollectionView.delegate = self;
    
    self.myCollectionView.dataSource = self;
    // Initialization code
}

- (void)setModels:(NSMutableArray<MarketHSubModel *> *)models{
    _models = models;
    
    [self.myCollectionView reloadData];

}




- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    
    
    return 1;
    
    
}


- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    
    return self.models.count;
    
    
}


- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    
        RecommdCollectionCell *temp = (RecommdCollectionCell *)[collectionView dequeueReusableCellWithReuseIdentifier:[RecommdCollectionCell identifierStr] forIndexPath:indexPath];
        
        temp.model = self.models[indexPath.item];
        
        return temp;
        
        
   
    
    
}

/*
 {"shopCarList":[{"goods":[{"goods_name":"钓鱼岛矿泉水","goods_image_url":"http:\/\/mall.xjscvip.com\/data\/upload\/shop\/store\/goods\/1\/1_05548291508149339_360.jpg","store_name":"小鲸商城","is_virtual":"0","count":"1","goods_image":"1_05548291508149339.jpg","isSelect":"1","detail_url":"http:\/\/mall.xjscvip.com\/wap\/tmpl\/product_detail.html?goods_id=336","goods_salenum":"138","goods_price":"72.00","goods_id":"336","goods_jingle":""}],"store_name":"小鲸商城","checked":"1"}]}
 
 */



- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    
    GoodDetailController *tempVC = [[GoodDetailController alloc]init];
    
    MarketHSubModel *subModel = self.models[indexPath.item];
    
    OneGoodsModel *tempModel = [[OneGoodsModel alloc]init];

    tempModel.goods_id = subModel.goods_id;
    
    tempModel.goods_image_url = subModel.pic_cover_small;
    
    tempVC.goodsModel = tempModel;
    
    [self.viewController.navigationController pushViewController:tempVC animated:YES];
    
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
